<!-- 图文问诊 -->
<template>
	<view class="image-text-inquiry-wrapper">
		<h1>{{doctor.z_name}}</h1>
		<p>请详细描述你的病情，有助于我更准确的分析，同时保证你的隐私安全！</p>
		<uni-section title="预选症状" type="line">
			<view class="tag-view" v-for="(item, index) in doctor.authority" :key="index">
				<uni-tag :inverted="true" :text="item.bq" />
			</view>
		</uni-section>
		<u--textarea v-model="formData.text" placeholder="请详细描述您的病情" height="120"></u--textarea>
		<!-- <u-upload :fileList="fileList" name="file" multiple :maxCount="5"></u-upload> -->
		<u-button type="success" text="提交询问" @click="submitForm()"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				zid: '',
				doctor: {},
				formData: {
					text: '',
					typedate: 0,
					upload_picture_list: []
				},
				fileList: []
			}
		},
		onLoad(option) {
			this.loadDoctor(option.zid)
			this.zid = option.zid
		},
		methods: {
			loadDoctor(zid) {
				this.$app._get('entry/wxapp/zhuanjia.getdocinfo', {
					zid: zid
				}, (result) => {
					this.doctor = result
					console.log(result)
				})
			},
			
			submitForm() {
				uni.showModal({
					title: '提示',
					content: '确定提交询问吗？',
					success: (res) => {
						if (res.confirm) {
							this.api_addbl()
						} else if (res.cancel) {
				
						}
					}
				});
			},

			api_addbl() {
				let openid = uni.getStorageSync('openid')
				let currentUserCard = uni.getStorageSync('current_user_card')
				this.$app._post_form('entry/wxapp/tuwen.addbl', {
					openid:openid,
					zid: this.zid,
					key_words: 'tuwenwenzhen',
					cfstate: 1,
					conets: JSON.stringify(this.formData),
					money: 0,
					j_id: currentUserCard.numcard,
					ifgk: 0,
					addnum: 0,
					biaoqian: [],
					coupon_dk: 0,
					old_money: 0,
					coupon_id: '',
					yid: '',
					year_dk: ''
				}, (result) => {
					console.log(result)
					uni.navigateTo({
						url: '/pages/global/successMessage?msg=提交成功'
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.image-text-inquiry-wrapper {
		width: 100%;
		height: 100%;
		background-color: #fff;
		padding: 20px;
		box-sizing: border-box;

		h1 {
			font-size: 1.5rem;
		}

		p {
			color: #757575;
		}

		.tag-view {
			display: inline-block;
			margin-bottom: 15px;
			margin-right: 5px;
		}
	}
</style>